<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const search = "?a=1&b=2&c=3";
      // URLSearchParams // 专门用来处理url参数
      const usp = new URLSearchParams(search);
      // usp get属性  你输入key 返回值
      // console.log(usp.get("a"));
      // console.log(usp.get("b"));
      // console.log(usp.get("c"));

      // usp 也是可以遍历  forEach  value 和 key
      const obj = {};
      usp.forEach((value, key) => {
        console.log(key, value);

        // [key]  key 表示变量
        obj[key] = value;
      });
      console.log(obj);
    </script>
  </body>
</html>
